package com.seezoon.interfaces;

import com.seezoon.application.device.dto.CreateFenceCmd;
import com.seezoon.application.device.dto.DeleteFenceCmd;
import com.seezoon.application.device.dto.FencePageQry;
import com.seezoon.application.device.dto.SoundRecordingCmd;
import com.seezoon.application.device.dto.UpdateFenceCmd;
import com.seezoon.application.device.dto.clientobject.FenceCO;
import com.seezoon.application.device.executor.CreateFenceCmdExe;
import com.seezoon.application.device.executor.DeleteFenceCmdExe;
import com.seezoon.application.device.executor.FencePageQryExe;
import com.seezoon.application.device.executor.SoundRecordingCmdExe;
import com.seezoon.application.device.executor.UpdateFenceCmdExe;
import com.seezoon.infrastructure.dto.Page;
import com.seezoon.infrastructure.dto.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "设备控制", description = "设备控制处理")
@RequiredArgsConstructor
@Slf4j
@RestController
@RequestMapping("/device")
public class DeviceController {

    private final SoundRecordingCmdExe soundRecordingCmdExe;
    private final CreateFenceCmdExe createFenceCmdExe;
    private final UpdateFenceCmdExe updateFenceCmdExe;
    private final DeleteFenceCmdExe deleteFenceCmdExe;
    private final FencePageQryExe fencePageQryExe;

    @Operation(summary = "发送录音命令")
    @PostMapping("/sound_recording")
    public Response soundRecording(@RequestBody SoundRecordingCmd cmd) {
        return soundRecordingCmdExe.execute(cmd);
    }

    @Operation(summary = "创建围栏")
    @PostMapping("/fence/create")
    public Response<FenceCO> createFence(@RequestBody CreateFenceCmd cmd) {
        return createFenceCmdExe.execute(cmd);
    }

    @Operation(summary = "更新围栏")
    @PostMapping("/fence/update")
    public Response<FenceCO> updateFence(@RequestBody UpdateFenceCmd cmd) {
        return updateFenceCmdExe.execute(cmd);
    }

    @Operation(summary = "删除围栏")
    @PostMapping("/fence/delete")
    public Response deleteFence(@RequestBody DeleteFenceCmd cmd) {
        return deleteFenceCmdExe.execute(cmd);
    }

    @Operation(summary = "查询围栏")
    @PostMapping("/fence/query")
    public Response<Page<FenceCO>> queryFence(@RequestBody FencePageQry qry) {
        return fencePageQryExe.execute(qry);
    }
} 